package tt.dz.scheduletask.tasks;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import tt.dz.dao.base.BaseDao;
import tt.dz.scheduletask.ScheduledTask;
import tt.dz.service.middleware.OmsCharStationService;

@Component
public class UpdateStationScoreByDayTask implements ScheduledTask
{
	private Log log = LogFactory.getLog(UpdateStationScoreByDayTask.class);


	@Autowired
	OmsCharStationService omsCharStationService;
	@Autowired
	BaseDao baseDao;
	@Override
	public void execute()
	{
		log.info("UpdateStationScoreByDayTask 开始执行");
		
		try
		{
			if (omsCharStationService.updateStationScore()) {
				Boolean flag = baseDao.exec("delete from instruction_log where datediff(curdate(), create_time)>=2");
				if(!flag){
					log.info("instructionLogTask 执行失败");
				}else{
					log.info("instructionLogTask 执行成功");
				}
				log.info("UpdateStationScoreByDayTask 执行完毕");
			}else {
				log.info("UpdateStationScoreByDayTask 执行失败");
			}
			
		}
		catch (Exception e)
		{
			log.info("UpdateStationScoreByDayTask 执行失败");
			log.error(e.getMessage(), e);
		}
	}
}
